package model;

/**
 * Class for the supervisor for unfolding of the graph
 * @author DarkoLaptop2
 *
 */
public class UnfoldingTransitionSystem extends TransitionSystem {
	
	/**
	 *  The constructor of the class
	 */
	public UnfoldingTransitionSystem() {
		super();
	}
	
	/** Method for getting the node index for a given node name and variable values 
	 * returns -1 if that state doesn't exist
	 * @param nodeName the name of the value
	 * @param variableTable - the variables value
	 * @return int - the index of the node or -1
	 */
	public int getNodeIndex(String nodeName, VariableHashTable variableTable){
		NodeUnfoldingTransitionSystem node=new NodeUnfoldingTransitionSystem(-1, nodeName, variableTable);
		for(int i=0;i<nodesCount;i++){
			if(adjList[i].equals(node))
				return i;
		}
		return -1;
	}
	
	/** Method for adding new node to the graph for a given node name and variable vallues
	 * @param index - the index of the node
	 * @param name - the name of the node
	 * @param variablesValuesTable - the variable values table
	 */
	public void addNode(int index,String name,VariableHashTable variablesValuesTable){
		adjList[index]=new NodeUnfoldingTransitionSystem(index, name, variablesValuesTable);
		nodesCount++;
		if(index>maxNodeIndex)
			maxNodeIndex=index;
	}
}
